package svc

import (
	"go-zero-demo/apps/user/cmd/rpc/internal/config"
	"go-zero-demo/apps/user/model"
	"go-zero-demo/common/db"
	"gorm.io/gorm"
)

type ServiceContext struct {
	Config    config.Config
	DB        *gorm.DB
	UserModel *model.UserModel
}

func NewServiceContext(c config.Config) *ServiceContext {
	DB := db.InitGorm(c.DB.DataSource)
	return &ServiceContext{
		Config:    c,
		DB:        DB,
		UserModel: model.NewUserModel(DB),
	}
}
